<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ForumThreads.ascx.cs" Inherits="forums_controls_forums_ForumThreads" %>
<%@ Register Src="../misc/Pager.ascx" TagName="Pager" TagPrefix="uc1" %>

<asp:Repeater runat="server" ID="gridThreads">
    <HeaderTemplate>
        <table width="100%" cellpadding="2" cellspacing="1">
            <asp:Literal runat="server" ID="ltrHeader"
                Visible='<%# ShowHeader %>'>
                <tr class="forum_grid_header">
                    <td width="50%">
                        Thread
                    </td>
                    <td width="10%">
                        Replies
                    </td>
                    <td width="10%">
                        Views
                    </td>
                    <td width="30%">
                        Last Post
                    </td>
                </tr>
        </asp:Literal>
    </HeaderTemplate>
    <ItemTemplate>
        <tr class="forum_grid_item">
            <td align="left" valign="middle" width="50%">
                <div class="forum_grid_item_title">
                    <%# ThreadLocked((DAL.Thread.ThreadStatus)Eval("Status")) %>
                    <%# ThreadPriority((DAL.Thread.ThreadPriority)Eval("Priority")) %>
                    <asp:HyperLink runat="server" ID="lnkFirstPost"
                        NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/thread.aspx?t={0}", Eval("ID")) %>'
                        Text='<%# Helpers.StringHelper.SafeFormat(Eval("FirstPost.Subject")) %>'
                        ToolTip='<%# GetFirst500Chars(Helpers.StringHelper.SafeFormat(Eval("FirstPost.Content") as string)) %>'
                    />
                    <uc1:Pager ID="Pager1" runat="server"
                        TotalPages='<%# Eval("TotalPages") %>'
                        HeaderText="(Page "
                        FooterText=")"
                        MaximumPages="10"
                        CurrentPage="0"
                        UrlFormat='<%# Helpers.StringHelper.SafeFormat("~/forums/thread.aspx?t={0}&page={{0}}", Eval("ID")) %>' />
                </div>
                <div class="forum_grid_item_description">
                    <asp:HyperLink runat="server" ID="lnkThreadStarter"
                        Text='<%# Helpers.StringHelper.SafeFormat(Eval("FirstPost.User.Username")) %>'
                        NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/profile.aspx?u={0}", Eval("FirstPost.User.ID")) %>' />
                </div>
            </td>
            <td align="center" valign="middle" width="10%">
                <%# Eval("TotalReplies") %>
            </td>
            <td align="center" valign="middle" width="10%">
                <%# Eval("TotalViews") %>
            </td>
            <td align="left" valign="middle" width="30%">
                <asp:HyperLink runat="server" ID="lnkUser"
                    Text='<%# Helpers.StringHelper.SafeFormat(Eval("LastPost.User.Username")) %>'
                    NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/profile.aspx?u={0}", Eval("LastPost.User.ID")) %>'/>
                <sup>
                <asp:HyperLink runat="server" ID="lnkLastPost"
                    NavigateUrl='<%# Helpers.StringHelper.SafeFormat("~/forums/thread.aspx?p={0}#{0}", Eval("LastPost.ID")) %>'>
                    <img border="0"
                        src='<%# Helpers.StringHelper.GetRelativePath("images/rightarrows.gif")  %>'
                        align="absmiddle"/>
                </asp:HyperLink>
                </sup>
                <%# (Eval("LastPost") as DAL.Post).DatePosted.ToString("yyyy-MMM-dd hh:mm tt") %>            
            </td>
        </tr>
    </ItemTemplate>
    <FooterTemplate>
            <asp:Literal runat="server" ID="ltrNoItems"
                Visible='<%# !GridHasItems %>'>
                <tr class="forum_grid_item">
                    <td colspan="4">
                        This forum doesn't have any threads.
                    </td>
                </tr>
            </asp:Literal>
        </table>
    </FooterTemplate>
</asp:Repeater>